package form.utils
{
	public class FunctionArray
	{
		private var arr:Array;
		
		public function FunctionArray()
		{
			reset();
		}
		
		public function reset():void
		{
			arr = [];
		}
		
		public function addFunction(fun:Function, ...args):void
		{
			arr.push(new FunctionWithParams(fun, args));
		}
		
		public function execute(thisObj:Object):void
		{
			while(length > 0)
			{
				var item:FunctionWithParams = arr.shift() as FunctionWithParams;
				item.execute(thisObj);
			}
		}
		
		public function get isEmpty():Boolean
		{
			return !arr || arr.length == 0
		}
		
		public function get length():uint
		{
			return arr.length;
		}

	}
}
class FunctionWithParams
{
	public var fun:Function;
	public var params:Array = [];
	
	public function FunctionWithParams(fun:Function, params:Array)
	{
		this.fun = fun;
		this.params = params;
	}
	
	public function execute(thisObj:Object):void
	{
		fun.apply(thisObj, params);
	}
}